package com.evaluationSystem.service;

import com.evaluationSystem.entity.Appraise;
import com.evaluationSystem.entity.dto.ScoreDto;
import com.evaluationSystem.entity.vo.AnalyseListVo;
import com.evaluationSystem.entity.vo.AnalyseOwnVo;
import com.evaluationSystem.mapper.AppraiseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AnalyseService {

    @Autowired
    private AppraiseMapper appraiseMapper;

    public List<AnalyseListVo> getAnalyseListss(ScoreDto scoreDto, String questionId) {
        // 这里是获取 AnalyseListVo 的逻辑
        List<AnalyseListVo> analyseListVos = appraiseMapper.appraiseAnalyseList(scoreDto);
        // 其他逻辑
        return analyseListVos;
    }


    public double getQuanzhong(String userId, String questionId, String reviewerName) {
        Appraise appraise = new Appraise();
        appraise.setAppraiserPhone(userId);
        appraise.setQuestionId(questionId);
        appraise.setAssessedName(reviewerName);
        AnalyseOwnVo evaluateObject = appraiseMapper.getEvaluateObjects(appraise);
        if (evaluateObject != null && evaluateObject.getAppraiserUser() != null) {
            for (AnalyseOwnVo.AppraiserUser appraiserUser : evaluateObject.getAppraiserUser()) {
                if (appraiserUser.getAssessedId().equals(reviewerName)) {
                    return appraiserUser.getQuanzhong();
                }
            }
        }
        return 0.0;
    }

}
